<?php

include('../functions/db.php');
include('../functions/common.php');

$message = mres(($_POST['message']));  
$username = mres(($_POST['username']));

//$message = convertToTinyUrl($message);
$message = htmlentities($message);
insertChatMessage($message, $username);

$returnUrl = mres(($_GET['redirectUrl']));

$querystring="";
$args = explode("&", $_SERVER['QUERY_STRING']);
foreach ($args as $arg) {
    $keyval = explode("=", $arg);
    if ($keyval[0] != "redirectUrl" And $keyval[0] != "page")
        $querystring .= "&" . $arg;
}

header('Location: ../?page=' . $returnUrl . $querystring . '#chat');
?>
